<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let tw={
            data:[1,26,45,4,54,4]
        };
        //给父级添加方法
        Object.setPrototypeOf(tw,{max(){
               return this.data.sort((a,b)=> b-a)[0];
        }});
        console.log(tw.max());//54
             

        //假设还有其他的对象向使用这个方法的话
        let grade_class={
            lessons:{js:55,css:44,mysql:98},
            get data(){
                return Object.values(this.lessons); //找到data属性，返回
            }
        }

        console.log(tw.max.call(grade_class));//98 
        console.log(Math.max.call(null,...tw.data));

        console.log(Math.max.apply(null,Object.values(grade_class.lessons)));
       console.log("_________________________");
       //或者直接用max方法，不用apply
        console.log(Math.max(...tw.data));
        console.log(Math.max(...Object.values(grade_class.lessons)));
   </script>
</body>
</html>